

#ifndef QYEG0420RWS19A_H
#define QYEG0420RWS19A_H

#include "epdif.h"
#define  QYEG0420RWS19A  
#define  MONO 1  

// Display resolution
#define EPD_WIDTH       400
#define EPD_HEIGHT      300
#define MAX_LINE_BYTES     50
#define MAX_COLUMN_BYTES   300
#define ALLSCREEN_BYTES   15000

// QYEG0420RWS19A commands
#define DRIVER_OUTPUT_CONTROL                       0x01 //驱动输出控制
#define GATE_DRIVING_VOLTAGE                       0x03  //门极驱动电压
#define SOURCE_DRIVING_VOLTAGE                     0x04  //驱动电压电源
#define DEEP_SLEEP_MODE                             0x10 //深度休眠模式
#define DATA_ENTRY_MODE_SETTING                     0x11 //数据输入模式设置
#define SW_RESET                                    0x12 //软件复位
#define TEMPERATURE_SENSOR_CONTROL                  0x18 //温度传感器和风扇控制
#define MASTER_ACTIVATION                           0x20 //主激活
#define DISPLAY_UPDATE_CONTROL_1                    0x21 //显示更新控制
#define DISPLAY_UPDATE_CONTROL_2                    0x22
#define WRITE_RAM_BW                                0x24 //写内存黑白
#define WRITE_RAM_RED                       	    0x26 //写内存红 
#define WRITE_VCOM_REGISTER                         0x2C //编写VCOM注册
#define WRITE_LUT_REGISTER                          0x32 //编写LUT注册
#define SET_DUMMY_LINE_PERIOD                       0x3A //设定哑线周期
#define SET_GATE_LINE_WIDTH                         0x3B //SET_GATE_LINE_WIDTH
#define BORDER_WAVEFORM_CONTROL                     0x3C //边境波形控制
#define SET_RAM_X_ADDRESS_START_END_POSITION        0x44 //设置内存x地址的起始和结束位置
#define SET_RAM_Y_ADDRESS_START_END_POSITION        0x45 //设置内存y地址的起始和结束位置
#define SET_RAM_X_ADDRESS_COUNTER                   0x4E //设置RAM x地址计数器
#define SET_RAM_Y_ADDRESS_COUNTER                   0x4F //设置RAM y地址计数器

extern const unsigned char LUT_DATA[];

class Epd : public EpdIf {
public:
    int width;
    int height;

    Epd();
    ~Epd();
    int Init(void);
    void SendCommand(unsigned char command);
    void SendData(unsigned char data);
    void WaitUntilIdle(void);
    void Reset(void);
    void SetFrameScreen_ALL(const unsigned char* frame_buffer_black, const unsigned char* frame_buffer_red);
    void SetFrameScreen_BW(const unsigned char* frame_buffer_black);
    void SetFrameScreen_RED(const unsigned char* frame_buffer_red);
    void ClearFrameMemory(void);
    void DisplayFrame(void);
    void SetLut(void);
    void Sleep(void);

private:
    unsigned int reset_pin;
    unsigned int dc_pin;
    unsigned int cs_pin;
    unsigned int busy_pin;

};

#endif /* QYEG0420RWS19A_H */

/* END OF FILE */
